package com.yc.javaee.servlet.d0615;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "LogoutServlet", value = "/logout.s")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        // 1. 在会话中移除 loginedUser
        session.removeAttribute("loginedUser");
        // 2. 将会话销毁
        session.invalidate();
        // 响应重定向
        response.sendRedirect("0615/index.html");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
